package pers.xiaoliang.concurrency.example.singleton;

import lombok.extern.slf4j.Slf4j;
import pers.xiaoliang.concurrency.annotation.NotRecommend;
import pers.xiaoliang.concurrency.annotation.ThreadSafe;

/**
* @description: 单例发布对象(懒汉模式- 线程安全 性能不好)
* @author: xiaoliang.liu
* @date: 2018/7/28 13:36
* @version v1.0
*/
@Slf4j
@ThreadSafe
@NotRecommend
public class SingletonExample3 {

    private SingletonExample3() {}


    /** 单例对象 */
    private static SingletonExample3 instance = null;

    /** 静态工厂方法 */
    public static synchronized SingletonExample3 getInstance() {
        if (instance == null) {
            instance = new SingletonExample3();
        }
        return instance;
    }

    public static void main(String[] args) {

    }
}
